<?php
/* @var $this TenderController */
/* @var $dataProvider CActiveDataProvider */

$this->breadcrumbs=array(
	Yii::t('tender','Tenders'),
);

$this->menu=array(
	array('label'=>Yii::t('tender','Create Tender'), 'url'=>array('create')),
	array('label'=>Yii::t('tender','Manage Tender'), 'url'=>array('admin')),
);
?>

<h1>Tenders</h1>

<?php $this->widget('application.extensions.jqrelcopy.JQRelcopy', array(
	//the id of the 'Copy' link in the view, see below.
	'id' => 'copylink',
 
	//add a icon image tag instead of the text
	//leave empty to disable removing
	'removeText' => Yii::t('tender','Remove'),
 
	//htmlOptions of the remove link
	'removeHtmlOptions' => array('style'=>'color:red'),
 
	//options of the plugin, see http://www.andresvidal.com/labs/relcopy.html
	'options' => array(
 
       //A class to attach to each copy
      'copyClass'=>'newcopy',
 
      // The number of allowed copies. Default: 0 is unlimited
      'limit'=>0,
 
      //Option to clear each copies text input fields or textarea
      'clearInputs'=>true,
 
      //A jQuery selector used to exclude an element and its children
      'excludeSelector'=>'.skipcopy',

	)
)); ?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm'); ?>
	
	<div class="row">
		<?php echo CHtml::label(Yii::t('tender','Company'),''); ?>
		<?php echo CHtml::label(Yii::t('tender','Contact'),''); ?>
		<?php echo CHtml::label(Yii::t('tender','Phone'),''); ?>
		<?php echo CHtml::label(Yii::t('tender','Fax'),''); ?>
		<?php echo CHtml::label(Yii::t('tender','Email'),''); ?>
	</div>

<?php 
if($model){
	foreach($model as $k=>$v){
	if($k==0){
?>
	<div class="row copy">
		<?php echo CHtml::textField('Namelist[company]',$v['sname'],array('size'=>'50')); ?>
		<?php echo CHtml::textField('Namelist[contact]',$v['cname']); ?>
		<?php echo CHtml::textField('Namelist[phone]',$v['phone']); ?>
		<?php echo CHtml::textField('Namelist[fax]',$v['fax']); ?>
		<?php echo CHtml::textField('Namelist[email]',$v['email']); ?>
		<?php echo CHtml::hiddenField('Namelist[bid]',$v['bid']); ?>
	</div>
<?php	
	}else{
?>
	<div class="row copy newcopy">
		<?php echo CHtml::textField('Namelist[company]',$v['sname'],array('size'=>'50')); ?>
		<?php echo CHtml::textField('Namelist[contact]',$v['cname']); ?>
		<?php echo CHtml::textField('Namelist[phone]',$v['phone']); ?>
		<?php echo CHtml::textField('Namelist[fax]',$v['fax']); ?>
		<?php echo CHtml::textField('Namelist[email]',$v['email']); ?>
		<?php echo CHtml::hiddenField('Namelist[bid]',$v['bid']); ?>
		<a href="#" onclick="$(this).parent().remove(); return false;" style="color:red"><?php echo Yii::t('tender','Delete');?></a>
	</div>	
<?php	
	}
}
}else{
?>	
	<div class="row copy">
		<?php echo CHtml::textField('Namelist[company][]','',array('size'=>'50')); ?>
		<?php echo CHtml::textField('Namelist[contact][]',''); ?>
		<?php echo CHtml::textField('Namelist[phone][]',''); ?>
		<?php echo CHtml::textField('Namelist[fax][]',''); ?>
		<?php echo CHtml::textField('Namelist[email][]',''); ?>
		<?php echo CHtml::hiddenField('Namelist[bid][]',''); ?>
	</div>
<?php } ?>
	<a id="copylink" href="#" rel=".copy"><?php echo Yii::t('tender','Add Line');?></a>
	<div class="row buttons">
		<?php echo CHtml::submitButton('Submit'); ?>
	</div>

<?php $this->endWidget(); ?>	
</div>

<?php
if ($dumpModel) {
    echo "<h3>Dump of the model data</h3>";
    echo "<p>";
    CVarDumper::dump($model,20,true);
    echo "</p>";
}
?>